<include file="public:header"/>

<div class="toptit">修改顾问</div>
<form action="{:U('edit')}" method="post" name="FormData" id="FormData" enctype="multipart/form-data">
    <div class="form_main width120">
        <div class="fl">姓名:</div>
        <div class="fr">
            <input name="name" type="text" class="input_text_default middle" maxlength="25" value="{$info.name}"/>
        </div>
        <div class="fl">手机:</div>
        <div class="fr">
            <input name="mobile" type="text" class="input_text_default middle" maxlength="11" value="{$info['mobile']}" onKeyUp="if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,'');"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"/>
        </div>
        <div class="fl">电话:</div>
        <div class="fr">
            <input name="tel" type="text" class="input_text_default middle" maxlength="15" value="{$info['tel']}"/>
        </div>
        <div class="fl">QQ:</div>
        <div class="fr txt">
            <input name="qq" type="text" class="input_text_default middle" maxlength="15" value="{$info.qq}" onKeyUp="if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,'');"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"/>
        </div>
        <div class="fl">照片:</div>
        <div class="fr J-file-input-box">
            <if condition="$info['pic']">
                <div class="file-input-src">
                    <div class="img"><img src="{:attach($info['pic'],'consultant')}?_t={:time()}" align=absmiddle></div>
                    <div class="del file-input-del" id="J_upload_cos_img" name="pic">点击更换</div>
                </div>
            <else/>
                <div class="file-input-src hid">
                    <div class="img"></div>
                    <div class="del file-input-del" id="" name="pic">点击更换</div>
                </div>
                <div class="file-input-block" id="J_upload_cos_img" name="pic"><span class="o-txt">上传</span>照片</div>
            </if>
            <input type="hidden" class="file-input-save-name" name="pic" value="{$info.pic}">
        </div>
        <div class="fl"></div>
        <div class="fr">
            <input type="hidden" name="id" value="{$info.id}">
            <input type="button" class="admin_submit" value="保存" id="J_submit" />
            <input type="button" class="admin_submit" value="返回" onClick="history.go(-1)"/>
        </div>
        <div class="clear"></div>
    </div>
</form>

</div>
<include file="public:footer"/>
</body>
<script type="text/javascript">
  var uploadUrl = "{:U('Upload/form_upload')}";
</script>
<script src="__ADMINPUBLIC__/js/ajaxfileupload.js"></script>
<script src="__ADMINPUBLIC__/js/fileupload.js"></script>
<script type="text/javascript">
    $(document).ready(function () {

        $('#J_submit').click(function(){
            var that = $(this);
            if(that.hasClass('disabled')){
                return false;
            }
            that.val('正在保存...').addClass('disabled');
            $.post("{:U('edit')}",$('#FormData').serialize(),function(result){
                if(result.status==1){
                    disapperTooltip("success", result.msg,function(){
                        location.href='{:U("Consultant/index")}';
                    });
                }else{
                    disapperTooltip("remind", result.msg,function(){
                        that.val('保存').removeClass('disabled');
                    });
                    return false;
                }
            },'json');
        });
      // 上传网站首页Logo
      $.upload('#J_upload_cos_img',{name:'pic',dir:'consultant'},function(result){
        if(result.error == 1){
          var htmlResult = '<img src="'+ result.url.src +'" align=absmiddle>';
          $('#J_upload_cos_img').closest('.J-file-input-box').find('.file-input-src .img').html(htmlResult);
          $('#J_upload_cos_img').closest('.J-file-input-box').find('.file-input-save-name').val(result.url.savename);
          if ($('#J_upload_cos_img').hasClass('file-input-block')) {
            $('#J_upload_cos_img').closest('.J-file-input-box').find('.file-input-src').removeClass('hid');
            var $delObj = $('#J_upload_cos_img').closest('.J-file-input-box').find('.file-input-del');
            $('#J_upload_cos_img').remove();
            $delObj.attr('id', "J_upload_cos_img_change_btn");
            $.upload('#J_upload_cos_img_change_btn',{name:'pic',dir:'consultant'},function(result){
              if(result.error == 1){
                var htmlResult = '<img src="'+ result.url.src +'" align=absmiddle>';
                $('#J_upload_cos_img_change_btn').closest('.J-file-input-box').find('.file-input-src .img').html(htmlResult);
                $('#J_upload_cos_img_change_btn').closest('.J-file-input-box').find('.file-input-save-name').val(result.url.savename);
              } else {
                disapperTooltip("remind", "上传失败："+result.message);
              }
            })
          }
        } else {
          disapperTooltip("remind", "上传失败："+result.message);
        }
      });
    });
</script>
</html>